package com.ggjj.filter_interceptor_controlleradvice_aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author gengjian
 * @date 2025/02/14 20:28:53
 * 切面类    新建一个切面类 三个注解是标配
 *          新建一个切入点 pointcut往哪切
 *          五大通知随织入，业务落地切面成
 */
@Component
@Slf4j
@Aspect
public class AspectDemo {
    @Pointcut("@target(org.springframework.web.bind.annotation.RestController)" +
            "&& within(com.ggjj.filter_interceptor_controlleradvice_aop..*) && execution(public * *(..))")
    public void pointCut(){}

    @Around(value = "pointCut()")
    public Object aroundMethodExecution(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        log.info("Aop 进入");
        //主业务逻辑放行
        Object proceed = proceedingJoinPoint.proceed();
        log.info("Aop 退出");
        return proceed;
    }
}
